#include<bits/stdc++.h>
using namespace std;
const int N=1000010;
int l,r;
int n,t,cnt;
int a[N];

int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    while(t--){
        cin>>n;
        int cnt=0;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        int l=1 ,r=n;
        for(int i=1;i<=n;i++){
            while(l<r){
            if(a[l]==a[r] )
            {
                cnt+=a[l];
            }
             r--;}
            l++;
            r=n;
        }
        cout<<cnt<<endl;}
    return 0;
}
